home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Sample Code / AppsToGo / DTS.Draw / TExtSelectObj.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-09-22  |  3.7 KB  |  158 lines  |  [TEXT/MPS ]

  1. /*
  2. ** Apple Macintosh Developer Technical Support
  3. **
  4. ** File:        TExtSelectObj.c
  5. ** Written by:    Eric Soldan
  6. **
  7. ** Copyright © 1993 Apple Computer, Inc.
  8. ** All rights reserved.
  9. */
  10.  
  11. /* You may incorporate this sample code into your applications without
  12. ** restriction, though the sample code has been provided "AS IS" and the
  13. ** responsibility for its operation is 100% yours.  However, what you are
  14. ** not permitted to do is to redistribute the source as "DSC Sample Code"
  15. ** after having made changes. If you're going to re-distribute the source,
  16. ** we require that you make it clear in the source that the code was
  17. ** descended from Apple Sample Code, but that you've made changes. */
  18.  
  19. /* See the files "=How to write your app" and "=Using TreeObj.c" for information
  20. ** on this function. */
  21.  
  22. /* This file implements the messages for the round-rect object.  Many of the messages
  23. ** can be handled by the rect object, as they deal with a rect structure.  Only
  24. ** a few of them are round-rect-specific. */
  25.  
  26. /* It would seem that you would want a custom hit-test message handler here, but
  27. ** the rect object first checks to see if the hit is within the bounding box of
  28. ** the object, and if so, it then calls the object to return the region.  This
  29. ** allows the rect object to generically handle hit-testing. */
  30.  
  31.  
  32.  
  33. /*****************************************************************************/
  34.  
  35.  
  36.  
  37. #include "App.h"            /* Get the application includes/typedefs, etc.    */
  38. #include "App.protos.h"        /* Get the prototypes for the application.        */
  39.  
  40. #ifndef __OSEVENTS__
  41. #include <OSEvents.h>
  42. #endif
  43.  
  44. #ifndef __OSUTILS__
  45. #include <OSUtils.h>
  46. #endif
  47.  
  48. #ifndef __QUICKDRAW__
  49. #include <Quickdraw.h>
  50. #endif
  51.  
  52. #ifndef __TREEOBJ2__
  53. #include "TreeObj2.h"
  54. #endif
  55.  
  56. #ifndef __UTILITIES__
  57. #include "Utilities.h"
  58. #endif
  59.  
  60.  
  61.  
  62. /*****************************************************************************/
  63.  
  64.  
  65.  
  66. static ExtSelectObjPeek    *gMWERKSDebug;
  67.     /* For Metroweks debugging of AppsToGo "objects", you need an instance of the
  68.     ** same type you wish to view it in the debugger.  Now we have an instance. */
  69.  
  70.  
  71.  
  72. /*****************************************************************************/
  73. /*****************************************************************************/
  74.  
  75. #ifdef applec
  76. #pragma segment DTSDrawSeg2
  77. #endif
  78.  
  79. /*****************************************************************************/
  80. /*****************************************************************************/
  81.  
  82.  
  83.  
  84. long    TExtSelectObj(TreeObjHndl hndl, short message, long data)
  85. {
  86.     Rect        rct;
  87.     RgnHandle    rgn, accumRgn;
  88.  
  89.     switch (message) {
  90.         case FREEMESSAGE:
  91.         case COPYMESSAGE:
  92.         case UNDOMESSAGE:
  93.         case CONVERTMESSAGE:
  94.         case FREADMESSAGE:
  95.         case FWRITEMESSAGE:
  96.         case HREADMESSAGE:
  97.         case HWRITEMESSAGE:
  98.         case HITTESTMESSAGE:
  99.         case GETOBJRECTMESSAGE:
  100.         case SETOBJRECTMESSAGE:
  101.         case SECTOBJRECTMESSAGE:
  102.         case GETBBOXMESSAGE:
  103.         case CLICKMESSAGE:
  104.         case KEYMESSAGE:
  105.         case SETSELECTMESSAGE:
  106.         case GETSELECTMESSAGE:
  107.         case SIZEMESSAGE:
  108.         case COMPAREMESSAGE:
  109.             return(TRectObj(hndl, message, data));
  110.             break;
  111.  
  112.         case INITMESSAGE:
  113.             break;
  114.  
  115.         case GETRGNMESSAGE:
  116.             rgn      = NewRgn();
  117.             accumRgn = (RgnHandle)data;
  118.             if (accumRgn)
  119.                 if (GetHandleSize((Handle)accumRgn) > 10000)
  120.                     return((long)rgn);
  121.             rct = mDerefCommon(hndl)->rect;
  122.             RectRgn(rgn, &rct);
  123.             if (accumRgn)
  124.                 UnionRgn(rgn, accumRgn, accumRgn);
  125.             return((long)rgn);
  126.             break;
  127.  
  128.         case DRAWMESSAGE:
  129.             rct = mDerefRRect(hndl)->rect;
  130.             switch (data) {
  131.                 case DRAWOBJ:
  132.                     PenMode(patXor);
  133.                     PenPat((ConstPatternParam)&qd.gray);
  134.                     FrameRect(&rct);
  135.                     PenNormal();
  136.                     break;
  137.                 case ERASEOBJ:
  138.                     EraseRect(&rct);
  139.                     break;
  140.             }
  141.             break;
  142.  
  143.         case PRINTMESSAGE:
  144.             break;
  145.  
  146.         case VHMESSAGE:
  147.             break;
  148.  
  149.         default:
  150.             break;
  151.     }
  152.  
  153.     return(noErr);
  154. }
  155.  
  156.  
  157.  
  158.